1 Public Class FrmCAT_GROUP_ADD
2 Dim StockID As Integer
3 Private Sub FrmCAT_GROUP_ADD_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
4 Me.Text = "Group"
5 End Sub
6
7 Private Sub FrmCAT_GROUP_ADD_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
8 StockID = globalID
9 If Split(Me.Text, " - ")(1) = "Add" Then
10 txtgname.Text = ""
11 txtgdesc.Text = ""
12 Else
13 sqlSTR = "SELECT * FROM TBL_Group WHERE Group_ID =" & StockID
14 ExecuteSQLQuery(sqlSTR)
15 If sqlDT.Rows.Count > 0 Then
16 txtgname.Text = sqlDT.Rows(0)("Group_Name")
17 txtgdesc.Text = sqlDT.Rows(0)("Group_Description")
18 End If
19 End If
20 End Sub
21
22 Private Sub cmdsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
23 Dim sqlstr As String
24 If txtgname.Text = "" Then
25 MsgBox("Group name is recquired !!", MsgBoxStyle.Exclamation, "Sales and Inventory")
26 Exit Sub
27 End If
28 If Split(Me.Text, " - ")(1) = "Add" Then
29 sqlstr = "INSERT INTO TBL_Group (Group_Name, Group_Description) VALUES ('" & R_eplace(txtgname.Text) & "', '" & R_eplace(txtgdesc.Text) & "')"
30 ExecuteSQLQuery(sqlstr)
31 Else
32 sqlstr = "UPDATE TBL_Group SET Group_Name ='" & txtgname.Text & "', " & _
33 "Group_Description ='" & txtgdesc.Text & "'" & _
34 "WHERE Group_ID =" & StockID
35 ExecuteSQLQuery(sqlstr)
36 End If
37 FillListView(ExecuteSQLQuery("SELECT Group_ID AS 'ID', Group_Name AS 'Name', Group_Description AS 'Description' FROM TBL_Group"), FrmCatList.lstCat, 0)
38 Me.Close()
39 End Sub
40
41 Private Sub cmdclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclose.Click
42 Me.Close()
43 End Sub
44
45 Private Sub txtgname_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtgname.TextChanged
46 txtgname.Text = filter_Special_Char(str_Filter(txtgname, 65, 122, 32, 40))
47 End Sub
48
49 Private Sub txtgdesc_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtgdesc.TextChanged
50 txtgdesc.Text = filter_Special_Char(str_Filter(txtgdesc, 65, 122, 32, 40))
51 End Sub
52 End Class